package com.hualan.service.impl;

import com.hualan.mapper.PricingTypeMapper;
import com.hualan.pojo.PricingType;
import com.hualan.pojo.Result;
import com.hualan.service.PricingTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PricingTypeServiceImpl implements PricingTypeService {
    @Autowired
    private PricingTypeMapper pricingTypeMapper;
    @Override
    public Result addPricingType(PricingType pricingType) {
        try {
            pricingTypeMapper.addPricingType(pricingType);
            return Result.success();
        } catch (Exception e) {
            return Result.error("添加失败");
        }

    }

    @Override
    public Result updatePricingType(PricingType pricingType) {
        try {
            pricingTypeMapper.updatePricingType(pricingType);
            return Result.success();
        } catch (Exception e) {
            return Result.error("更新失败");
        }
    }

    @Override
    public Integer getTypeIdByTypeName(String typeName) {
        return pricingTypeMapper.getTypeIdByTypeName(typeName);
    }

    @Override
    public String getTypeNameById(Integer typeId) {
        return pricingTypeMapper.getTypeNameById(typeId);
    }
}

